package com.itheima.case2.service.impl;

import com.itheima.case2.dao.RoleMapper;
import com.itheima.case2.pojo.po.Role;
import com.itheima.case2.service.RoleService;
import com.itheima.case2.utils.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class RoleServiceImpl implements RoleService {
    @Override
    public List<Role> queryAllRoles() {
        //使用工具类创建会话对象
        SqlSession session = SqlSessionUtil.getSession();
        //获取代理对象
        RoleMapper mapper = session.getMapper(RoleMapper.class);
        //使用代理对象调用方法
        List<Role> roles = mapper.queryAllRoles();
        //释放资源
        session.close();
        //返回结果
        return roles;
    }
}
